package com.yohann.boot.common.annotation;

import com.yohann.boot.common.enums.ValidEnum;
import com.yohann.boot.common.validator.EnumValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

/**
 * 枚举验证接口
 *
 * @author Yeung Wah
 * @since 2021/11/20
 */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.PARAMETER})
@Constraint(validatedBy = EnumValidator.class)
public @interface EnumValid {

    /**
     * 枚举类
     *
     * @return 枚举类字节码信息
     */
    Class<? extends ValidEnum> clazz();

    /**
     * 报错信息
     *
     * @return 报错信息
     */
    String message() default "enum is not contains this value";

    /**
     * 验证组别
     *
     * @return 验证组别class
     */
    Class<?>[] groups() default {};

    /**
     * Payload
     *
     * @return Payload
     */
    Class<? extends Payload>[] payload() default {};
}